﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing.Design;

namespace BPM.Base.WFLib.CustomerAttribute
{
    public class CheckBoxUITypeEditorBase : System.Drawing.Design.UITypeEditor
    {
        //ListBox list;

        protected CheckBoxSelector us1;
        IWindowsFormsEditorService editorSsevice;
        public  CheckBoxUITypeEditorBase()
        {
           
            us1 = new CheckBoxSelector();
            us1.btnCancel.Click += new EventHandler(CloseDropDown);

            us1.btnOK.Click += new EventHandler(CloseDropDown);

            this.FillCollection();
            //us1.list.Add("123");
            //us1.list.Add("456");
            us1.FillPanel();
            
        }

        protected virtual void  FillCollection()
        {
            ;
        }

       

        void CloseDropDown(object sender, EventArgs e)
        {
            editorSsevice.CloseDropDown();
        }

        public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.DropDown;
        }


        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            editorSsevice = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (editorSsevice != null)
            {

                editorSsevice.DropDownControl(us1);

                if (us1.value == null)
                {
                    return "";
                }
                else
                {
                    return us1.value;
                }

            }
            return value;
        }

       
    }

    

}
